package com.qidianit.mes.production.controller;

import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.pojo.WorkmanshipComposition;
import com.qidianit.mes.production.service.WorkmanshipCompositionService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*;

/**
 * @Author djl
 * @Time 2024/10/21 11:11
 */
@RestController
@RequestMapping("/composition")
@CrossOrigin
public class WorkmanshipCompositionController {
    @Autowired
    private WorkmanshipCompositionService workmanshipCompositionService;
    @GetMapping("/list")
    public MESResult list(Integer workmanshipId,
                          @RequestParam(defaultValue = "1")int page,
                          @RequestParam(defaultValue = "10")int limit){
        System.out.println("==========================");
        return workmanshipCompositionService.list(workmanshipId,page,limit);
    }
    @PostMapping("/add")
    public MESResult addNewComposition(@RequestBody WorkmanshipComposition workmanshipComposition){
        return workmanshipCompositionService.addNewComposition(workmanshipComposition);
    }
    @PostMapping("/edit")
    public MESResult editComposition(@RequestBody WorkmanshipComposition workmanshipComposition){
        return workmanshipCompositionService.editComposition(workmanshipComposition);
    }
    @GetMapping("/query")
    public MESResult query(Integer workmanshipId,Integer processNumber){
        return workmanshipCompositionService.query(workmanshipId,processNumber);
    }
}
